package main

import (
	"encoding/json"
	"fmt"
)

type UserInfo struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

func main() {
	u1 := UserInfo{
		ID:   111,
		Name: "张云雷",
	}
	b, err := json.Marshal(struct {
		*UserInfo
		Token string `json:"token"`
	}{
		UserInfo: &u1,
		Token:    "5555555",
	})
	if err != nil {
		fmt.Println("json marshal failed,err:", err)
	}

	fmt.Printf("%s", b) // {"id":111,"name":"张云雷","token":"5555555"}

}
